﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Apply.aspx.cs" Inherits="WebForm_LeaveData_Apply" %>

<%@ Register Src="~/AttendanceWebForm/LeaveData/Form.ascx" TagPrefix="My" TagName="Form" %>
<script runat="server">
    /* list */
    protected void gv_DataBinding(object sender, EventArgs e)
    {
        var db = new DB("Attendance");
        var dt = db.Execute(string.Format(@"SELECT ld.* FROM LeaveData ld WHERE ld.OrgID IN ({0}) AND (ld.CreateBy = @EmpID OR ld.EmpID = @EmpID)
                    AND Status NOT IN ('D') "
            , MyObj.JoinFormat(",", "'{0}'", RoleManager.Current.GetOrgForCurrentComp()))
            , new DBParameter("EmpID", EmpManager.Current.EmpID));

        //LocManager.Current.Translate(dt, "OrgData", "OrgName");

        (sender as DataBoundControl).DataSource = dt;
    }
    /* end of list */

    /* form */

    /* end of form */
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <My:Form ID="Form1" runat="server" OnSaved="Form1_Saved"></My:Form>
    <p>
    </p>
    <My:MyGridView ID="gv" runat="server" OnDataBinding="gv_DataBinding" OnRowCommand="gv_ItemCommand"
        DataKeyNames="LeaveID">
        <Columns>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, EmpID   %>">
                <ItemTemplate>
                    <%#Eval("EmpID") %>
                    <%# LocManager.Current.GetText("EmpData", "EmpName", Eval("EmpID"))%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, OrgID   %>">
                <ItemTemplate>
                    <%# LocManager.Current.GetText("OrgData", "OrgName", Eval("OrgID")) %>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, LeaveType   %>">
                <ItemTemplate>
                    <%# CodeManager.Current.GetText("LeaveData", "LeaveType", Eval("LeaveType"))%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, LeaveStartDate   %>">
                <ItemTemplate>
                    <%#Eval("LeaveStartDate", "{0:yyyy/MM/dd HH:mm}")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, LeaveEndDate   %>">
                <ItemTemplate>
                    <%#Eval("LeaveEndDate", "{0:yyyy/MM/dd HH:mm}")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: LeaveData, Hours   %>">
                <ItemTemplate>
                    <%#Eval("Hours")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: Form, CreateDate   %>">
                <ItemTemplate>
                    <%#Eval("CreateDate")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$Resources: Form, Status   %>">
                <ItemTemplate>
                    <%# CodeManager.Current.GetText("LeaveData", "Status", Eval("Status"))%>
                </ItemTemplate>
            </asp:TemplateField>
            <%--                    <asp:TemplateField HeaderText="<%$Resources: Form, CreateBy   %>">
                        <ItemTemplate>
                            <%#Eval("CreateBy")%> <%# LocManager.Current.GetText("EmpData", "EmpName", Eval("CreateBy"))%>
                        </ItemTemplate>
                    </asp:TemplateField>--%>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="btnDelete" runat="server" CommandName="MyDelete" Text="<%$Resources: Form, btnDelete %>"></asp:LinkButton>
                    <ajax:ConfirmButtonExtender ID="cbDelete" runat="server" TargetControlID="btnDelete"
                        ConfirmText="<%$Resources: Form, cbDelete %>">
                    </ajax:ConfirmButtonExtender>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </My:MyGridView>

</asp:Content>
